API Documentation
Classes | Public Member Functions | List of all members
nkWinUi::TabWindow Class Referenceabstract

A graphical tab window. More...

Inheritance diagram for nkWinUi::TabWindow:
nkWinUi::Component nkExport::Exportable

Classes

class  Tab
 Holds information about a tab in the window. More...
 

Public Member Functions

 TabWindow (MainSystem *parentSystem)
 
 ~TabWindow ()
 
virtual TabaddTab (const nkMemory::StringView &label)
 
TabgetTabByLabel (const nkMemory::StringView &label) const
 
TabgetTabById (int id) const
 
TabgetTabByIndex (unsigned int index) const
 
virtual TabgetTabByMouseRel (const nkMaths::Point &mouseRel) const =0
 
int getTabIndex (Tab *tab) const
 
unsigned int getTabCount () const
 
virtual void reorderTab (Tab *tab, unsigned int newIndex)
 
virtual void changeTabLabel (const nkMemory::StringView &oldLabel, const nkMemory::StringView &newLabel)
 
virtual void eraseTab (const nkMemory::StringView &label)
 
virtual LayoutsetLayout (LAYOUT_TYPE layoutType) override
 
virtual void setActiveTab (Tab *toActivate)
 
TabgetActiveTab () const
 
virtual void adaptToDisplayArea (Window *toAdapt) const =0
 
void setTabSwitchCallback (std::function< bool(TabWindow *, TabWindow::Tab *, bool)> value)
 
const std::function< bool(TabWindow *, TabWindow::Tab *, bool)> & getTabSwitchCallback () const
 
virtual void exportIntrospection (nkExport::Node *rootNode) override
 
void importClassFromTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkWinUi::Component
 Component (MainSystem *parentSystem)
 
virtual ~Component ()
 
LayoutgetLayout () const
 
ThemegetTheme () const
 
nkMaths::Point getPositionInParent () const
 
nkMaths::Point getPositionInScreen () const
 
int getWidth () const
 
int getHeight () const
 
nkMaths::Rectangle getAreaInParent () const
 
nkMaths::Rectangle getAreaInScreen () const
 
virtual nkMaths::Point getBorderExtents () const
 
virtual float getBorderExtent (BORDER_KIND border) const
 
virtual int getLayoutAllowedWidth () const
 
virtual int getLayoutAllowedHeight () const
 
virtual int getLayoutAllowedOffsetX () const
 
virtual int getLayoutAllowedOffsetY () const
 
bool isInitialized () const
 
ComponentgetParentComponent () const
 
COMPONENT_TYPE getComponentType () const
 
nkMemory::StringView getComponentName () const
 
bool getVisibility () const
 
virtual nkMemory::StringView getLabel () const
 
void * getData () const
 
bool isEnabled () const
 
bool isForegroundWindow () const
 
unsigned int getZDepth () const
 
bool getVisibleOnLoad () const
 
std::function< bool(Component *)> getCloseCallback () const
 
std::function< void(Component *, bool)> getVisibilityCallback () const
 
std::function< void(Component *, const ClickEventData &)> getClickCallback () const
 
std::function< void(Component *, const WheelEventData &)> getWheelCallback () const
 
std::function< void(Component *, const KeyEventData &)> getKeyCallback () const
 
virtual void setTheme (Theme *theme)
 
virtual void setPositionInParent (nkMaths::Point position)
 
virtual void setPositionInScreen (nkMaths::Point position)
 
virtual void setSize (int width, int height)
 
virtual void setWidth (int width)
 
virtual void setHeight (int height)
 
void setMinSize (unsigned int width, unsigned int height)
 
void setMaxSize (unsigned int width, unsigned int height)
 
void setRatio (float widthOverHeight)
 
virtual void setAreaInParent (const nkMaths::Rectangle &area)
 
virtual void setAreaInScreen (const nkMaths::Rectangle &area)
 
virtual void setParentComponent (Component *parent, bool makeItVisible=true)
 
virtual void setLabel (const nkMemory::StringView &label)
 
void setComponentName (const nkMemory::StringView &name)
 
virtual void setVisibility (bool value)
 
void setData (void *data)
 
void setEnabled (bool value)
 
void setVisibleOnLoad (bool value)
 
void setCloseCallback (std::function< bool(Component *caller)> callback)
 
void setVisibilityCallback (std::function< void(Component *caller, bool visibility)> callback)
 
void setClickCallback (std::function< void(Component *caller, const ClickEventData &eventData)> callback)
 
void setWheelCallback (std::function< void(Component *caller, const WheelEventData &eventData)> callback)
 
void setKeyCallback (std::function< void(Component *caller, const KeyEventData &eventData)> callback)
 
void addChild (Component *child, bool makeItVisible=true)
 
void removeChild (Component *child)
 
void removeChild (unsigned int index)
 
ComponentgetChild (unsigned int index)
 
unsigned int getChildIndex (Component *child)
 
void unloadWithChildren ()
 
void loadWithChildren ()
 
void updateZDepth ()
 
void bringToForeground ()
 
void focusWindow ()
 
nkMaths::Point getCoordRelativeFromAbsolute (const nkMaths::Point &absCoords)
 
nkMaths::Point getCoordAbsoluteFromRelative (const nkMaths::Point &relCoords)
 
virtual void load ()=0
 
virtual void unload ()=0
 
void reload ()
 
virtual void updateWindow ()
 
nkImages::Image paintToImage (bool withFrame=false)
 
void simulateEvent (const InputDescriptor &inputDescription)
 
void onSized ()
 
virtual void exportClassToTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable ()
 
virtual ~Exportable ()
 

Detailed Description

A graphical tab window.

Constructor & Destructor Documentation

◆ TabWindow()

nkWinUi::TabWindow::TabWindow ( MainSystem parentSystem)

Constructor.

Parameters
parentSystemThe parent system in which the component will live.
Remarks
See ComponentManager::createOrRetrieve().

◆ ~TabWindow()

nkWinUi::TabWindow::~TabWindow ( )

Destructor.

Member Function Documentation

◆ addTab()

virtual Tab* nkWinUi::TabWindow::addTab ( const nkMemory::StringView label)
virtual

Adds a tab to the window.

Parameters
labelThe tab label to insert.
Returns
The newly created tab.
Remarks
The TabWindow owns the Tab memory.

◆ getTabByLabel()

Tab* nkWinUi::TabWindow::getTabByLabel ( const nkMemory::StringView label) const
Parameters
labelThe label of the tab to retrieve.
Returns
The tab attached to given labl if available, nullptr else.

◆ getTabById()

Tab* nkWinUi::TabWindow::getTabById ( int  id) const
Parameters
idThe id of the tab to retrieve.
Returns
The tab attached to given id if available, nullptr else.

◆ getTabByIndex()

Tab* nkWinUi::TabWindow::getTabByIndex ( unsigned int  index) const
Parameters
indexThe index of the tab to retrieve, corresponding to its index in the displaying order, from left to right.
Returns
The tab at given index if available, nullptr else.

◆ getTabByMouseRel()

virtual Tab* nkWinUi::TabWindow::getTabByMouseRel ( const nkMaths::Point mouseRel) const
pure virtual
Parameters
mouseRelThe cursor position, in pixels relative to the window, to pick for a tab.
Returns
The tab head touched by the mouse position if available, nullptr else.

◆ getTabIndex()

int nkWinUi::TabWindow::getTabIndex ( Tab tab) const
Parameters
tabThe tab from which the index is wanted.
Returns
The index requested if available, -1 else.
Remarks
An index can change in the lifetime of a tab through reordering or erasing. As such, the index returned by this method should not be stored, unless you know tab memory won't change.

◆ getTabCount()

unsigned int nkWinUi::TabWindow::getTabCount ( ) const
Returns
The number of tabs within the window.

◆ reorderTab()

virtual void nkWinUi::TabWindow::reorderTab ( Tab tab,
unsigned int  newIndex 
)
virtual

Updates a given tab's index, reinserting it in the tab set at given index. This will change a given tab's position in the window.

Parameters
tabThe tab to move around.
newIndexThe new index to move it to.
Remarks
This will move around the tab, possibly pushing other tabs to make a spot.

◆ changeTabLabel()

virtual void nkWinUi::TabWindow::changeTabLabel ( const nkMemory::StringView oldLabel,
const nkMemory::StringView newLabel 
)
virtual

Changes the label of a tab.

Parameters
oldLabelThe old label to find back the tab to alter.
newLabelThe new label to set to the tab.

◆ eraseTab()

virtual void nkWinUi::TabWindow::eraseTab ( const nkMemory::StringView label)
virtual

Erases a tab and free its memory.

Parameters
labelThe label of the tab to erase.

◆ setLayout()

virtual Layout* nkWinUi::TabWindow::setLayout ( LAYOUT_TYPE  layoutType)
overridevirtual

Sets the layout to use in the currently active window, associated to the active tab. See Component::setLayout() for details.

Reimplemented from nkWinUi::Component.

◆ setActiveTab()

virtual void nkWinUi::TabWindow::setActiveTab ( Tab toActivate)
virtual

Sets the tab currently active and displayed.

Parameters
toActivateThe tab to active.

◆ getActiveTab()

Tab* nkWinUi::TabWindow::getActiveTab ( ) const
Returns
The active tab.

◆ adaptToDisplayArea()

virtual void nkWinUi::TabWindow::adaptToDisplayArea ( Window toAdapt) const
pure virtual

Adapts a window to fit within the tab window displaying area.

Parameters
toAdaptThe window which size should be adapted.

◆ setTabSwitchCallback()

void nkWinUi::TabWindow::setTabSwitchCallback ( std::function< bool(TabWindow *, TabWindow::Tab *, bool)>  value)

Sets the tab switch callback.

Parameters
valueThe callback to use. It will receive the calling component, the selected tab and whether the tab is changing and not yet fully selected. The callback should return a boolean stating whether the tab can be switched to while it changing (true) or if the change should not occur (false). When a switch occur, this callback is called twice : once with the changing flag on, and a second time with it off if true has been returned during the first call.

◆ getTabSwitchCallback()

const std::function<bool (TabWindow*, TabWindow::Tab*, bool)>& nkWinUi::TabWindow::getTabSwitchCallback ( ) const
Returns
Currently set tab switch callback.

◆ exportIntrospection()

virtual void nkWinUi::TabWindow::exportIntrospection ( nkExport::Node rootNode)
overridevirtual

◆ importClassFromTree()

void nkWinUi::TabWindow::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

The documentation for this class was generated from the following file: